package cfar.actors.test.bkp.statusreport;

import cfar.actors.Message;
import cfar.actors.Node;
import cfar.actors.distributed.CRCActor;
import cfar.actors.distributed.Signal;
import cfar.ff.data.Assocs.Assoc2;
import cfar.ff.fun.F1;

import static cfar.ff.fun.Curry.*;
import static cfar.actors.Message.*;
import static cfar.utils.IO.*;

import java.io.IOException;
import java.net.InetAddress;

/**
 *
 * @author badi
 */
public class Main {

    final static F1<Integer, Integer> f = new F1<Integer, Integer>() {

        public Integer f(Integer a) {
            return a + 2;
        }
    };


    public static void main(String[] args) throws IOException, InterruptedException {

        // remote actor
        new Thread(new CRCActor("/tmp/cfar.sync", "cfs")).start();

        // local work
        Assoc2<InetAddress, Integer> loc = available_hosts("/tmp/cfar.sync", "cfs").head();
        Node n = new Node(loc.$1, loc.$2);
        n.tell(new Message(Signal.WorkF0, curry(f, 40)));
        System.out.println(n.call().payload);
        n.tell(stop);
    }
}
